package com.chenchao.javaabstract;

/**
 * @encoding : UTF-8
 * @Time : 2020/11/10 15:54
 * @Author : Chen Chao
 * @File : javaSE.com.chenchao.javaabstract.Test2.java
 * @Software : IntelliJ IDEA
 * @since : 1.8
 * 面向接口编程
 */
public class Test2 {
    public static void main(String[] args) {
        Computer computer = new Computer();
        Usbable mouse = new Mouse();
        Usbable keyboard = new Keyboard();
        computer.readData(mouse);
        computer.readData(keyboard);
    }
}
interface Usbable{
    void getData();
}
class Mouse implements Usbable{

    @Override
    public void getData() {
        System.out.println("鼠标移动");
    }
}
class Keyboard implements Usbable{

    @Override
    public void getData() {
        System.out.println("键盘敲击");
    }
}
class Computer {
    public void readData(Usbable usbable){
        usbable.getData();
    }
}